﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Hartley.ApplicationLogic;
using Hartley.DTOs;

namespace WebApplication1
{
    public partial class AddTeamMembers : System.Web.UI.Page
    {
        AdminAL adminAL = new AdminAL();
        StudentAL studentAL = new StudentAL();

        public Guid SelectedStaff
        {
            get
            {
                if (Session["StaffId"] == null)
                {
                    return adminAL.GetAllStaff()[0].StaffId;
                }
                else
                {
                    return new Guid(Session["StaffId"].ToString());
                }
            }
            set
            {
                Session["StaffId"] = value;
            }
        }

        public Guid SelectedStudent
        {
            get
            {
                if (Session["StudentId"] == null)
                {
                    return studentAL.GetStudents()[0].StudentId;
                }
                else
                {
                    return new Guid(Session["StudentId"].ToString());
                }
            }
            set
            {
                Session["StudentId"] = value;
            }
        }

        protected override void OnPreRenderComplete(EventArgs e)
        {
            base.OnPreRenderComplete(e);

            List<StaffDTO> staffDTO = adminAL.GetAllStaff();
            List<StudentDTO> studentDTO = studentAL.GetStudents();
            //ddlTeamMembersCoach.DataSource = staffDTO;
           // ddlTeamMembersCoach.DataTextField = "FullName";
            //ddlTeamMembersCoach.DataValueField = "StaffId";
            //ddlTeamMembersCoach.SelectedValue = SelectedStaff.ToString();
           // ddlTeamMembersCoach.DataBind();

           // ddlTeamMemberPOG.DataSource = staffDTO;
           // ddlTeamMemberPOG.DataTextField = "FullName";
           // ddlTeamMemberPOG.DataValueField = "StaffId";
           // ddlTeamMemberPOG.SelectedValue = SelectedStaff.ToString();
           // ddlTeamMemberPOG.DataBind();


           // ddlTeamMembersCaptain.DataSource = studentDTO;
           // ddlTeamMembersCaptain.DataTextField = "FullName";
          //  ddlTeamMembersCaptain.DataValueField = "StudentId";
          //  ddlTeamMembersCaptain.SelectedValue = SelectedStudent.ToString();
          //  ddlTeamMembersCaptain.DataBind();

          //  ddlTeamMembersViceCaptain.DataSource = studentDTO;
          //  ddlTeamMembersViceCaptain.DataTextField = "FullName";
         //   ddlTeamMembersViceCaptain.DataValueField = "StudentId";
         //   ddlTeamMembersViceCaptain.SelectedValue = SelectedStudent.ToString();
         //   ddlTeamMembersViceCaptain.DataBind();

        }
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnTeamMemberTeamAdd_Click(object sender, EventArgs e)
        {
            TeamDTO teamDTO = new TeamDTO
            {
                TeamId = Guid.NewGuid(),
                GameType = ddlTeamTypeOfGame.SelectedValue,
                Year =Convert.ToInt32(ddlTeamMemberYr.SelectedValue),
                AgeDivision = ddlTeamMemberAgeDivision.SelectedValue,
                Description = txtTeamDesc.Text == "" ? ddlTeamMemberAgeDivision.SelectedValue + ", " + ddlTeamTypeOfGame.SelectedValue + ", " + ddlTeamMemberYr.SelectedValue : txtTeamDesc.Text,
                TeamPhoto=fuTeamPhoto.FileName,
               // ModifiedBy="Tharsan",
                ModifiedTime=System.DateTime.Now
            };
            SportsAL sportsAL = new SportsAL();
            sportsAL.saveTeam(teamDTO);

        }
    }
}
